﻿using MediatR;
using NPOI.POIFS.FileSystem;
using Warehouse.API.Applcation.Command.AllocateCommand;
using Warehouse.API.Applcation.Command.EnterStoragesCommand;
using Warehouse.Infrstructre;
using Warehouse.Infrstructre.Interface;

namespace Warehouse.API.Applcation.CommandHandlers.AllocateCommandHandlers
{
    public class AllocateApprovalCommandHandlers : IRequestHandler<AllocateApprovalCommand, int>
    {
        private readonly IAllocateRepository _allocateRepository;
        private readonly IAllProductRepsitory _allProductRepsitory;
       public AllocateApprovalCommandHandlers(IAllocateRepository allocateRepository, IAllProductRepsitory allProductRepsitory)
        {
            _allocateRepository = allocateRepository;
            _allProductRepsitory = allProductRepsitory;
        }


        public async Task<int> Handle(AllocateApprovalCommand request, CancellationToken cancellationToken)
        {
            var list = await _allocateRepository.GetModelAsync(request.id);
            list.UpdName=request.Updname;
            list.UpdTime=DateTime.Now;
            list.AllocateState=request.state;
            list.ReasonReview=request.ReasonReview;
            await _allocateRepository.UpdateAsync(list);
            return 1;


        }
    }
}
